<template>
  <div class="bg">
    <!-- 头部 -->
    <Header title="系统管理—栏目管理"></Header>

    <!-- 搜索栏 -->
    <section class="search_bar">
      <LButton label="新增栏目" @click="repairDialog = true"></LButton>
    </section>
    <!-- 表格 -->
    <el-table :data="tableData" style="width: 100%" :default-sort="{prop:'b',order:descending}" border>
      <el-table-column label="编码" prop="a" />
      <el-table-column label="栏目名称" prop="b" />
      <el-table-column label="单位名称" prop="c" />
      <el-table-column label="操作" width="140">
        <template #default>
          <el-button type="primary" size="mini" @click="repairDialog2 = true">编辑</el-button>
          <el-button type="danger" size="mini" @click="del">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 弹出框：新增 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog" title="新增" width="40%" @close="repairDialogClose">
        <el-form label-width="80px" :model="repairForm" ref="repairFormRef" :rules="repairFormRules" size="small">
          <el-form-item label="栏目编码" prop="a" style="width:100%">
            <el-input v-model="repairForm.a"></el-input>
          </el-form-item>
          <el-form-item label="栏目名称" prop="a" style="width:100%">
            <el-input v-model="repairForm.a"></el-input>
          </el-form-item>
          <el-form-item label="选择单位" prop="b" style="width:100%">
            <el-select v-model="repairForm.b" style="width:100%">
              <el-option label="1" value="1"></el-option>
              <el-option label="2" value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="primary" size="mini" @click="repairSureBtn">确定</el-button>
            <el-button type="info" size="mini" @click="repairDialog = false">取消</el-button>
          </span>
        </template>
      </el-dialog>
    </div>

    <!-- 弹出框：编辑 -->
    <div v-dialogdrag>
      <el-dialog v-model="repairDialog2" title="编辑" width="40%" @close="repairDialog2Close">
        <el-form label-width="80px" :model="repairForm2" ref="repairForm2Ref" :rules="repairForm2Rules" size="small">
          <el-form-item label="栏目编码" prop="a" style="width:100%">
            <el-input v-model="repairForm.a"></el-input>
          </el-form-item>
          <el-form-item label="栏目名称" prop="a" style="width:100%">
            <el-input v-model="repairForm.a"></el-input>
          </el-form-item>
          <el-form-item label="选择单位" prop="b" style="width:100%">
            <el-select v-model="repairForm.b" style="width:100%">
              <el-option label="1" value="1"></el-option>
              <el-option label="2" value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button type="primary" size="mini" @click="repair2SureBtn">确定</el-button>
            <el-button type="info" size="mini" @click="repairDialog2 = false">取消</el-button>
          </span>
        </template>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import Header from "@/components/Header";
import moment from "moment";
import LInput from "../../../components/LInput.vue";
import LDateTimeSelect2 from "../../../components/LDateTimeSelect2.vue";
import LButton from "../../../components/LButton.vue";
import LSelect from "@/components/LSelect.vue";

export default {
  components: {
    Header,
    LInput,
    LDateTimeSelect2,
    LButton,
    LSelect,
  },
  data() {
    return {
      tableData: [],
      //=============================================
      repairDialog: false,
      repairForm: {},
      repairDialog2: false,
      repairForm2: {},
    };
  },
  mounted() {},
  beforeUnmount() {},
  methods: {
    //情况form表单
    repairDialogClose() {
      this.$refs.repairFormRef.resetFields(); //新增
    },
    repairDialog2Close() {
      this.$refs.repairForm2Ref.resetFields(); //编辑
    },
    //删除数据按钮
    del() {
      this.$confirm("此操作将永久删除该信息, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          // post("/airChannel/deleteAirChannel", { id: id }).then((res) => {
          //   // console.log(res);
          //   if (res.data.code == 200) {
          //     this.$message.success(res.data.data);
          //     this.getData();
          //   } else {
          //     this.$message.error(res.data.data);
          //   }
          // });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>


<style lang="less" scoped>
@import "../../OperaManage/opera.less";

.search_bar {
  width: 100%;
  height: 40px;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.row-1 {
  display: flex;
  justify-content: space-between;
  padding: 0 2vw 0 0;
}
</style>